package thread;

/**
 * 线程异常处理方案
 */
public class ThreadExceptionHandler {

    public static void main(String[] args) {

        Thread t1=new Thread(new Runnable() {
            @Override
            public void run() {
                int i=1/0;
            }
        });
        t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
            @Override
            public void uncaughtException(Thread t, Throwable e) {
                System.out.println(t.getName()+"-----"+e.getMessage());
            }
        });

        t1.start();

    }




}


